package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.RefPayInfo;
import com.softer.wxzj.service.RefPayInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * RefPayInfoController class
 *
 * @author wxr
 * @date 2019/7/1
 */
@RestController
@RequestMapping("/refPayInfo")
@Slf4j
public class RefPayInfoController {

    @Autowired
    RefPayInfoService refPayInfoService;

    /**
     * 凭证打印支付列表
     *
     * @param
     * @return
     */
    @RequestMapping("/getPayList")
    @LogRecord(description = "凭证打印支付列表", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.SELECT)
    public RefPayInfo getPayList(String reqId, String accNoState, String fuzzy) {
        return refPayInfoService.getPayList(reqId, accNoState, fuzzy);
    }

    /**
     * 有效日期
     *
     * @param id
     * @param vaildDate
     * @return
     */
    @RequestMapping("/changeDate")
    @LogRecord(description = "更改有效日期", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.UPDATE)
    public CommonResult changeDate(String id, String vaildDate) {
        return refPayInfoService.changeDate(vaildDate, id);
    }

    /**
     * 新增/修改
     *
     * @param refPayInfo
     * @return
     */
    @RequestMapping("/insertOrUpdate")
    @LogRecord(description = "新增/修改", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.UPDATE)
    public CommonResult insertOrUpdate(RefPayInfo refPayInfo) {
        return refPayInfoService.insertOrupdate(refPayInfo);
    }

    /**
     * 凭证冻结凭证信息
     *
     * @param refPayInfo
     * @return
     */
    @RequestMapping("/selectPayMessage")
    @LogRecord(description = "凭证冻结凭证信息", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.SELECT)
    public PageInfo<RefPayInfo> selectPayMessage(Page page, RefPayInfo refPayInfo) {
        return refPayInfoService.selectPayMessage(page, refPayInfo);
    }

    /**
     * 查询批量退款打印清册列表
     *
     * @param page
     * @param id
     * @return
     */
    @RequestMapping("/getBatchRefundPrintList")
    @LogRecord(description = "查询批量退款打印清册列表", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.SELECT)
    public PageInfo<RefPayInfo> getBatchRefundPrintList(Page page, @RequestParam("id") String id) {
        return refPayInfoService.getBatchRefundPrintList(page, id);
    }

    /**
     * 查询不汇总凭证打印
     *
     * @param id
     * @return
     */
    @RequestMapping("/getNoCollectPrintVoucher")
    @LogRecord(description = "查询不汇总凭证打印", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.SELECT)
    public RefPayInfo getNoCollectPrintVoucher(@RequestParam("id") String id) {
        return refPayInfoService.getNoCollectPrintVoucher(id);
    }

    /**
     * 查询汇总凭证打印
     *
     * @param id
     * @return
     */
    @RequestMapping("/getCollectPrintVoucher")
    @LogRecord(description = "查询汇总凭证打印", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.SELECT)
    public RefPayInfo getCollectPrintVoucher(@RequestParam("id") String id) {
        return refPayInfoService.getCollectPrintVoucher(id);
    }

    /**
     * 凭证冻结撤销信息
     *
     * @param id
     * @param accNoState
     * @return
     */
    @RequestMapping("/updateAccNoStateById")
    @LogRecord(description = "凭证冻结撤销信息", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.UPDATE)

    public CommonResult updateAccNoStateById(String id, String accNoState) {

        return refPayInfoService.updateAccNoStateById(id, accNoState);
    }

    @RequestMapping("/getPayListToBatchRefByReqId")
    @LogRecord(description = "查询批量打印凭证信息列表", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.SELECT)
    public List<RefPayInfo> getPayListToBatchRefByReqId(@RequestParam("reqId") String reqId,String fuzzy) {
        return refPayInfoService.getPayListToBatchRefByReqId(reqId,fuzzy);
    }

    /**
     * 凭证新增
     *
     * @param refPayInfo
     * @return
     */
    @RequestMapping("/add")
    @LogRecord(description = "凭证新增", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public CommonResult add(RefPayInfo refPayInfo) {
        return refPayInfoService.insert(refPayInfo);
    }

    /**
     * 不汇总状态生成新凭证
     *
     * @param id
     * @return
     */
    @RequestMapping("/addNewVoucher")
    @LogRecord(description = "凭证新增", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public CommonResult addNewVoucher(@RequestParam("id") String id) {
        return refPayInfoService.addNewVoucher(id);
    }

    /**
     * 汇总状态生成新凭证
     *
     * @param id
     * @return
     */
    @RequestMapping("/addNewCollectVoucher")
    @LogRecord(description = "凭证新增", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public CommonResult addNewCollectVoucher(@RequestParam("id") String id) {
        return refPayInfoService.addNewCollectVoucher(id);
    }

    /**
     * 凭证汇总
     *
     * @param reqId
     * @return
     */
    @RequestMapping("/collectVoucher")
    @LogRecord(description = "凭证汇总", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public CommonResult collectVoucher(@RequestParam("reqId") String reqId) {
        return refPayInfoService.collectVoucher(reqId);
    }

    /**
     * 日渐业务（临时）
     *
     * @param reqNo
     * @return
     */
    @RequestMapping("/selectReqPayInfo")
    @LogRecord(description = "日间业务", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public RefPayInfo selectReqPayInfo(String reqNo) {
        return refPayInfoService.selectReqPayInfo(reqNo);
    }

    /**
     * 日渐业务列表（临时）
     *
     * @param
     * @return
     */
    @RequestMapping("/selectReqPayInfoList")
    @LogRecord(description = "日间业务", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public PageInfo<RefPayInfo> selectReqPayInfoList(Page page, RefPayInfo refPayInfo) {
        return refPayInfoService.selectReqPayInfoList(page, refPayInfo);
    }

    @RequestMapping("/updateaccNoState")
    @LogRecord(description = "验证", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.UPDATE)
    public CommonResult updateaccNoState(String id, String accNoState, String state, String certDate) {
        return refPayInfoService.updateaccNoState(id, accNoState, state, certDate);
    }

    /**
     * 日渐业务列表（临时）
     *
     * @param
     * @return
     */
    @RequestMapping("/update")
    @LogRecord(description = "资金记账", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public CommonResult update(RefPayInfo refPayInfo) {
        return refPayInfoService.update(refPayInfo);
    }

    @RequestMapping("/selectRegionName")
    @LogRecord(description = "交易信息查询", operationUnit = LogOperationUnit.REF_PAT_INFO, operationType = LogOperationType.INSERT)
    public PageInfo<RefPayInfo> selectRegionName(Page page, RefPayInfo refPayInfo) {
        return refPayInfoService.selectRegionName(page, refPayInfo);
    }

    @RequestMapping("/selectPayNo")
    public List<RefPayInfo> selectPayNo() {
        return refPayInfoService.selectPayNo();
    }

    @RequestMapping("/selectPayInfoByNo")
    public RefPayInfo selectPayInfoByNo(String payNo) {
        return refPayInfoService.selectPayInfoByNo(payNo);
    }
}
